package com.community.web.controller.communityInteraction;

import java.util.List;
import com.community.body.domain.ZyCommunityInteraction;
import com.community.body.dto.InteractionDTO;
import com.community.body.service.IZyCommunityInteractionService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.community.common.annotation.Log;
import com.community.common.core.controller.BaseController;
import com.community.common.core.domain.AjaxResult;
import com.community.common.enums.BusinessType;

import com.community.common.core.page.TableDataInfo;

/**
 * 社区互动Controller
 * 
 * @author community
 * @date 2024-04-16
 */
@RestController
@RequestMapping("/oschina/interaction")
public class ZyCommunityInteractionController extends BaseController
{
    @Autowired
    private IZyCommunityInteractionService zyCommunityInteractionService;

    /**
     * 查询社区互动列表
     */
    @PreAuthorize("@ss.hasPermi('oschina:interaction:list')")
    @GetMapping("/list")
    public TableDataInfo list(InteractionDTO interactionDTO)
    {
        startPage();
        List<InteractionDTO> list = zyCommunityInteractionService.selectZyCommunityInteractionList(interactionDTO);
        return getDataTable(list);
    }

    /**
     * 热评
     */
    @PreAuthorize("@ss.hasPermi('oschina:interaction:list')")
    @GetMapping("/hotList")
    public TableDataInfo hotList(InteractionDTO interactionDTO)
    {
        startPage();
        List<InteractionDTO> list = zyCommunityInteractionService.selectHotZyCommunityInteractionList(interactionDTO);
        return getDataTable(list);
    }

//    /**
//     * 导出社区互动列表
//     */
//    @PreAuthorize("@ss.hasPermi('oschina:interaction:export')")
//    @Log(title = "社区互动", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, ZyCommunityInteraction zyCommunityInteraction)
//    {
//        List<ZyCommunityInteraction> list = zyCommunityInteractionService.selectZyCommunityInteractionList(zyCommunityInteraction);
//        ExcelUtil<ZyCommunityInteraction> util = new ExcelUtil<ZyCommunityInteraction>(ZyCommunityInteraction.class);
//        util.exportExcel(response, list, "社区互动数据");
//    }

    /**
     * 获取社区互动详细信息
     */
    @PreAuthorize("@ss.hasPermi('oschina:interaction:query')")
    @GetMapping(value = "/{interactionId}")
    public AjaxResult getInfo(@PathVariable("interactionId") Long interactionId)
    {
        return success(zyCommunityInteractionService.selectZyCommunityInteractionByInteractionId(interactionId));
    }

    /**
     * 新增社区互动
     */
//    @PreAuthorize("@ss.hasPermi('oschina:interaction:add')")
//    @Log(title = "社区互动", businessType = BusinessType.INSERT)
//    @PostMapping
//    public AjaxResult add(@RequestBody ZyCommunityInteraction zyCommunityInteraction)
//    {
//        return toAjax(zyCommunityInteractionService.insertZyCommunityInteraction(zyCommunityInteraction));
//    }

    /**
     * 修改社区互动
     */
    @PreAuthorize("@ss.hasPermi('oschina:interaction:edit')")
    @Log(title = "社区互动", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZyCommunityInteraction zyCommunityInteraction)
    {
        return toAjax(zyCommunityInteractionService.updateZyCommunityInteraction(zyCommunityInteraction));
    }

    /**
     * 删除社区互动
     */
    @PreAuthorize("@ss.hasPermi('oschina:interaction:remove')")
    @Log(title = "社区互动", businessType = BusinessType.DELETE)
	@DeleteMapping("/{interactionIds}")
    public AjaxResult remove(@PathVariable Long[] interactionIds)
    {
        return toAjax(zyCommunityInteractionService.deleteZyCommunityInteractionByInteractionIds(interactionIds));
    }
}
